﻿//Write a program that reads two arrays from the console and compares them element by element.


using System;

namespace EqualArrays
{
    class EqualArrays
    {
        static void Main()
        {
            int arr1, arr2;

            Console.Write("Array1 Lenght: ");
            arr1 = int.Parse(Console.ReadLine());
            int[] array1 = new int[arr1];                       //intiliaze array1[arr1]

            for (int i = 0; i < array1.Length; i++)
            {
                Console.Write("Array1[{0}] = ", i);
                array1[i] = int.Parse(Console.ReadLine());      //filling the array1
            }

            Console.Write("Array2 Lenght: ");
            arr2 = int.Parse(Console.ReadLine());
            int[] array2 = new int[arr2];                       //intiliaze array2[arr2]

            for (int i = 0; i < array2.Length; i++)
            {
                Console.Write("Array2[{0}] = ", i);
                array2[i] = int.Parse(Console.ReadLine());      //filling the array2
            }

            bool equal = true;

            if (array1.Length == array2.Length)                 //check if the lenght are equal
            {
                for (int i = 0; i < arr1; i++)                  //check the arrays indexes for equaling
                {
                    if (array1[i] == array2[i])
                    {
                        equal = true;
                    }
                    else
                    {
                        equal = false;
                        break;
                    }
                }
            }

            else
            {
                equal = false;
            }

            Console.WriteLine(equal ? "Array1 & Array2 are equal" : "Not Equal"); //print the result

        }
    }
}
